package com.ewzj.bigdata.mvp.presenter

import android.support.v4.app.Fragment
import android.support.v4.view.ViewPager
import android.support.v7.app.AppCompatActivity
import com.astuetz.PagerSlidingTabStrip
import com.ewzj.bigdata.app.config.AppKey
import com.ewzj.bigdata.mvp.contract.DecorateContract
import com.ewzj.bigdata.mvp.ui.adapter.TabAdapter
import com.ewzj.bigdata.mvp.ui.fragment.DecorateCompanyFragment
import com.ewzj.bigdata.mvp.ui.fragment.DecoratePicFragment
import com.ewzj.bigdata.mvp.ui.fragment.IFragmentloaddata
import com.jess.arms.mvp.BasePresenter
import javax.inject.Inject

/**
 * author:zhangjing
 * 作用:
 * return:
 */

class DecoratePresenter @Inject constructor(view: DecorateContract.View, model: DecorateContract.Model) :BasePresenter<DecorateContract.Model, DecorateContract.View>(model,view){
    val fragments= arrayListOf<Fragment>(DecoratePicFragment.newInstance(),DecorateCompanyFragment.newInstance())
    val title = arrayListOf<String>("装修图库", "装修公司")
    val context=mRootView as AppCompatActivity
    val adapter=TabAdapter(fragments,context.supportFragmentManager,title)
    fun initPagerSlide(vpcontent: ViewPager,pagertab : PagerSlidingTabStrip){
        vpcontent.setAdapter(adapter)
        pagertab.setViewPager(vpcontent)
    }

    fun searchData(type:Int,keyword:String){
        (fragments[type] as IFragmentloaddata).searchData(keyword)
    }
}
